$(function () {
    /**
     * 折叠按钮切换
     */
    (function () {
        $('.department .sidebar-menu').on('click', '.menu-dropdown', function () {
            if ($(this).next('.submenu').css('display') == 'none') {
                $(this).find('.collapse-right').removeClass('fa-angle-right').addClass('fa-plus');
                $(this).parent().siblings().find('.collapse-right').removeClass('fa-plus').addClass('fa-angle-right');
                $(this).parent().siblings().find('.fa-plus').removeClass('fa-plus');
            } else {
                $(this).find('.collapse-right').removeClass('fa-plus').addClass('fa-angle-right');
            }
        });
		//第二列li
        $('.department .sidebar-menu .submenu .submenu').on('click','li', function () {
            if (!$(this).find('i').is('.fa-plus')) {
                $(this).find('a').append('<i class="fa fa-trash-o  pull-right add_btn"></i>');
                $(this).find('a').append('<i class="fa fa-plus add_btn pull-right"></i>');
                //$(this).find('a').append('<i class="fa fa-plus-square-o add_btn pull-right"></i>');
                 $(this).siblings().find('i:not(".collapse-right")').remove('.fa-trash-o');
                $(this).siblings().find('i:not(".collapse-right")').remove('.fa-plus');
               
            }
        })
        
        //第三列li删除图标
        
    })();


      
    (function () {
      //添加疾病
        $('.sidebar-menu').on('click', '.fa-plus', function (event) {
        	if($(this).is('.collapse-right')){
        		$('.department-information,.position-information,.addPosition,.editPosition,.editDepartment,.JIBINGDepartment,.JIBING-edit,.add_zhibiao').hide();
            	$('.addDepartment').removeClass('hidden').show().addClass('animated bounceInRight');
        	}
        	if($(this).is('.add_btn')){
        		$('.department-information,.addDepartment,.position-information,.addPosition,.editPosition,.editDepartment,.JIBINGDepartment,.JIBING-edit,.add_zhibiao').hide();
            	$('.addPosition').removeClass('hidden').show().addClass('animated bounceInRight');
        	}
        	if($(this).is(".fa-jibing")){
        		$('.department-information,.addDepartment,.position-information,.addPosition,.editPosition,.editDepartment,.JIBINGDepartment,.JIBING-edit').hide();
            	$('.add_zhibiao').removeClass('hidden').show().addClass('animated bounceInRight');
        	}
            event.stopPropagation();
        });
        //删除按钮效果
        $(".first_list .sidebar-menu").on("click",".fa-trash-o",function(){
        	$(this).parents().find(".first_list").next().find(".position-name ul.sidebar-menu li ul.submenu").remove();
        	$(this).parent().parent().remove();
        })
        //指标项删除
        $(".position-name ul.sidebar-menu li ul.submenu").find(".fa-trash-o").click(function(){
        	$(this).parent().parent().remove();
        })
        
		//指标项
		$(".addPosition-btn").on("click", function() {
			$('.department-information,.position-information,.editPosition,.editDepartment,.addDepartment,.JIBING-edit,.JIBINGDepartment,.add_zhibiao').hide();
			$('.addPosition').removeClass('hidden').show();
		})
		
		//指标名称查看
		$(".zhibiao").on("click",function(){
			$('.position-information,.addPosition,.editPosition,.editDepartment,.addDepartment,.JIBINGDepartment,.JIBING-edit,.add_zhibiao').hide();
			$('.department-information').removeClass('hidden').show();
		})
 		//指标名称编辑
		$(".position-edit-1").on("click",function(){
			$('.department-information,.position-information,.addPosition,.editPosition,.addDepartment,.JIBINGDepartment,.JIBING-edit,.add_zhibiao').hide();
			$('.editDepartment').removeClass('hidden').show();
		})
		//疾病名称查看
		$(".fa-user").next().on("click",function(){
			$('.position-information,.department-information,.addPosition,.editPosition,.editDepartment,.addDepartment,.JIBING-edit,.add_zhibiao').hide();
			$('.JIBINGDepartment').removeClass('hidden').show();
		})
		//疾病名称编辑
		$(".position-edit-2").on("click",function(){
			$('.position-information,.department-information,.addPosition,.editPosition,.editDepartment,.addDepartment,.JIBINGDepartment,.add_zhibiao').hide();
			$('.JIBINGD_edit').removeClass('hidden').show();
		})
		
        //指标项编辑
        $('.department-edit').on('click', function () {
            $('.department-information,.addDepartment,.position-information,.addPosition,.editPosition,.JIBINGDepartment,.JIBING-edit,.add_zhibiao').hide();
            $('.editDepartment').removeClass('hidden').show();
            //点击取消按钮
            $('.cancel-btn').on('click', function () {
                $('.editDepartment,.addDepartment,.position-information,.addPosition,.editPosition,.JIBINGDepartment,.JIBING-edit,.add_zhibiao').hide();
                $('.department-information').removeClass('hidden').show();
            });
        });
    })();


    (function () {
        $('.position-name .sidebar-menu .menu-dropdown').on('click', '.fa-plus', function (event) {
            event.stopPropagation();
        });

        //点击职位名称显示职位信息
        $('.position-name .sidebar-menu > li > .submenu').on('click', 'li', function () { 
            $('.addDepartment,.department-information,.editDepartment,.addPosition,.editPosition,.JIBINGDepartment,.JIBING-edit,.add_zhibiao').hide();
            $('.position-information').removeClass('hidden').show();
        });

      

        //职位编辑
        $('.position-edit').on('click', function () {
            $('.department-information,.editDepartment,.position-information,.addPosition,.editPosition,.JIBINGDepartment').hide();
            $('.editPosition').removeClass('hidden').show();


            //点击取消按钮
            $('.cancel-btn').on('click', function () {
                $('.editDepartment,.addDepartment,.department-information,.addPosition,.editPosition,.JIBINGDepartment').hide();
                $('.position-information').removeClass('hidden').show();
            });
        });
    })();
});